package brad.zimmerman.dungeon.game;

import java.io.IOException;

import android.content.Context;
import android.media.MediaPlayer;

public class ClassBackgroundSound {
	MediaPlayer mediaPlayer;
	Context mediaContext;
	boolean running = false;
	private float volume = .6f;
	int currentlyPlaying = -3; //This means that nothing is playing
	ClassBackgroundSound(Context context){
		//mediaplayerMain = MediaPlayer.create(context, R.raw.lonestar);
		//mediaplayerMain.setLooping(true);
		//mediaPlayer = MediaPlayer.create(context, R.raw.background_default);
		//mediaPlayer.setLooping(true);
		this.mediaContext = context;
	}
	/*public void playBackgroundMain(){
		mediaplayerMain.start();
	}
	public void stopBackgroundMain(){
		mediaplayerMain.stop();
	}*/
	
	/*public String[] levelStrategies = {
			"Tutorial Level",
			"Forest",
	        "Desert",
	        "Dungeon",
	        "Factory",
	        "Library",
	        "Marsh",
	        "Snakepit",
	        "Temple",
	        "Crypt",
	        "Palace",
	        "Gateway",
	        "Tower",
	        "Cloud City",
	        "Inferno",
	        "Experiment with all of the classes first to figure out their strengths and weaknesses. Good luck"
	        
	};*/
	public void setBackgoundNoiseTheme(){
		mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_theme);
		mediaPlayer.setVolume(volume,volume);
		mediaPlayer.setLooping(true);
		currentlyPlaying=-1;
	}
	
	public void setLevelEndTheme(){
		mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_theme);
		mediaPlayer.setVolume(volume,volume);
		mediaPlayer.setLooping(true);
		currentlyPlaying=-2;
	}
	
	public void setBackgroundNoise(int noise){
		switch(noise){
			case 0:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_0);currentlyPlaying=0;break;
			case 1:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_1);currentlyPlaying=1;break;
			case 2:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_2);currentlyPlaying=2;break;
			case 3:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_3);currentlyPlaying=3;break;
			case 4:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_4);currentlyPlaying=4;break;
			case 5:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_5);currentlyPlaying=5;break;
			case 6:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_6);currentlyPlaying=6;break;
			case 7:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_7);currentlyPlaying=7;break;
			case 8:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_8);currentlyPlaying=8;break;
			case 9:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_9);currentlyPlaying=9;break;
			case 10:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_10);currentlyPlaying=10;break;
			case 11:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_11);currentlyPlaying=11;break;
			case 12:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_12);currentlyPlaying=12;break;
			case 13:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_13);currentlyPlaying=13;break;
			case 14:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_14);currentlyPlaying=14;break;
			case 15:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_14);currentlyPlaying=15;break;
			default:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_music_14);currentlyPlaying=1;break;
		/*
			case 0:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_beginninglevel);currentlyPlaying=0;break;
			case 1:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_default);currentlyPlaying=1;break;
			case 2:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_boxingmatch);currentlyPlaying=2;break;
			case 3:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_middleages);currentlyPlaying=3;break;
			case 4:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_chillfrogs);currentlyPlaying=4;break;
			case 5:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_twilightcastle);currentlyPlaying=5;break;
			case 6:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_tenselire);currentlyPlaying=6;break;
			case 7:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_ceremony);currentlyPlaying=7;break;
			case 8:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_mountaintown);currentlyPlaying=8;break;
			case 9:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_bedtime);currentlyPlaying=9;break;
			case 10:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_happycastle);currentlyPlaying=10;break;
			case 11:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_hanggliding);currentlyPlaying=11;break;
			case 12:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_magicsnake);currentlyPlaying=12;break;
			case 13:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_intheair);currentlyPlaying=13;break;
			case 14:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_tensebattle);currentlyPlaying=14;break;
			case 15:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_finaldefault);currentlyPlaying=15;break;
		default:mediaPlayer = MediaPlayer.create(mediaContext, R.raw.background_default);currentlyPlaying=1;break;
		*/
		}
		mediaPlayer.setVolume(volume,volume);
		mediaPlayer.setLooping(true);
	}
	public void playBackground(){
		if(!running){
			running = true;
			mediaPlayer.start();
		}
	}
	public void stopBackground(){
		if(running){
			running = false;
			mediaPlayer.stop();
		}
	}
	public void setVolume(float level){
    	volume = (level/100);
    }
	public float getVolume(){
		return volume * 100;
	}
}
